package bsf.baseservice.businessmq.dal;

import bsf.baseservice.businessmq.model.tb_mqpath_model;
import bsf.db.DbConn;
import bsf.util.ConvertUtil;

import java.util.List;
import java.util.Map;

public class tb_mqpath_dal
{
	public tb_mqpath_model get(DbConn PubConn, String mqpath)
	{

			StringBuilder stringSql = new StringBuilder();
			stringSql.append("select s.* from tb_mqpath s WITH(NOLOCK) where s.mqpath=?");
			List<Map<String,Object>> ds = PubConn.executeList(stringSql.toString(),
					new Object[]{mqpath});
			if (ds != null && ds.size() > 0)
			{
				return createModel(ds.get(0));
			}
			return null;

	}

	public java.util.Date getLastUpdateTimeOfMqPath(DbConn PubConn, String mqpath)
	{
			StringBuilder stringSql = new StringBuilder();
			stringSql.append("select lastupdatetime from tb_mqpath s WITH(NOLOCK) where s.mqpath=?");
		    List<Map<String,Object>> ds =	PubConn.executeList(stringSql.toString(), new Object[]{mqpath});
			if (ds != null && ds.size() > 0)
			{
				Object o = ds.get(0).get("lastupdatetime");
				if (o== null)
				{
					return null;
				}
					else
					{
						return ConvertUtil.objToDateTime(o);
					}
			}
			return null;

	}



	public tb_mqpath_model createModel(Map<String,Object> dr)
	{
		tb_mqpath_model o = new tb_mqpath_model();

		//
		if(dr.containsKey("id"))
		{
			o.id= ConvertUtil.objToInt(dr.get("id"));
		}
		//mq·��
		if(dr.containsKey("mqpath"))
		{
			o.mqpath= ConvertUtil.nullToStr(dr.get("mqpath"));
		}
		//��·����mq,����������ʱ��(�Ե�ǰ��ʱ��Ϊ׼)
		if(dr.containsKey("lastupdatetime"))
		{
			o.lastupdatetime= ConvertUtil.objToDateTime(dr.get("lastupdatetime"));
		}
		//mq����ʱ��(�Ե�ǰ��ʱ��Ϊ׼)
		if(dr.containsKey("createtime"))
		{
			o.createtime= ConvertUtil.objToDateTime(dr.get("createtime"));
		}
		return o;
	}
}